<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th,
        td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }

        th {
            background-color: #4CAF50;
            color: white;
        }
    </style>
</head>

<body>
    <table id="newsTable">
        <thead>
            <tr>
                <th>序号</th>
                <th>新闻标题</th>
                <th>新闻内容</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <script>
        const newsList1 = [
            { title: '新闻1', content: '新闻1内容' },
            { title: '新闻2', content: '新闻2内容' }
        ];
        const newsList2 = [
            { title: '新闻3', content: '新闻3内容' },
            { title: '新闻4', content: '新闻4内容' }
        ];

        // 合并两个数组
        const combinedNewsList = [...newsList1,...newsList2];

        // 获取表格的 tbody 元素
        const tableBody = document.getElementById('newsTable').getElementsByTagName('tbody')[0];

        // 循环遍历合并后的数组并创建表格行
        combinedNewsList.forEach((news, index) => {
            const row = tableBody.insertRow();
            const seqCell = row.insertCell(0);
            const titleCell = row.insertCell(1);
            const contentCell = row.insertCell(2);
            seqCell.textContent = index + 1;
            titleCell.textContent = news.title;
            contentCell.textContent = news.content;
        });
    </script>
</body>

</html>